package com.news.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.news.entity.User;
import com.news.service.UserService;


@WebServlet("/adminusereditpage")
public class AdminUserEditPageServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//1.获取到参数id
				String id = request.getParameter("id");
						
				//2.调用service，根据id查询用户数据
				UserService userService = new UserService();
				User user = userService.getById(Integer.parseInt(id));
						
				//3.将用户数据通过请求转发跳转到edit.jsp页面
				request.setAttribute("user", user);
				request.getRequestDispatcher("/jsp/adminedituser.jsp").forward(request, response);
	}

}
